<!DOCTYPE html>
<html lang="utf-8" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>失物招领后台管理系统</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.6 -->
    <link rel="stylesheet" th:href="@{/admin/bootstrap/css/bootstrap.min.css}" href="/static/bootstrap/css/bootstrap.min.css">
    <!-- Font Awesome -->
    <link rel="stylesheet" th:href="@{/admin/css/font-awesome.min.css}" href="/static/css/font-awesome.min.css">
    <!-- Ionicons -->
    <link rel="stylesheet" th:href="@{/admin/css/ionicons.min.css}" href="/static/css/ionicons.min.css">
    <!-- Theme style -->
    <link rel="stylesheet" th:href="@{/admin/dist/css/AdminLTE.min.css}" href="/static/dist/css/AdminLTE.min.css">
    <!-- iCheck -->
    <link rel="stylesheet" th:href="@{/admin/plugins/iCheck/square/blue.css}" href="/static/plugins/iCheck/square/blue.css">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->

</head>
<body class="hold-transition login-page">
<div class="login-box">
    <div class="login-logo">
        <b>失物招领后台管理系统</b>
    </div>
    <!-- /.login-logo -->
    <div class="login-box-body">
        <p class="login-box-msg">请您登录</p>
        <div class="form-group has-feedback">
            <input id="user"  type="email" class="form-control" placeholder="用户名">
            <span class="fa fa-fw fa-user form-control-feedback"></span>
            <span id="user_alert" style="color: red;visibility: hidden">请输入帐号</span>
        </div>
        <div class="form-group has-feedback">
            <input id="pwd" type="password" class="form-control" placeholder="密码">
            <span class="glyphicon glyphicon-lock form-control-feedback"></span>
            <span id="pwd_alert" style="color: red;visibility: hidden">请输入密码</span>
        </div>
        <div class="row">
            <div class="col-xs-8">
                <div class="checkbox icheck">
                    <label>
                        <input type="checkbox"> 记住我
                    </label>
                </div>
            </div>
            <!-- /.col -->
            <div class="col-xs-4">
                <button id="submitId" type="button" class="btn btn-primary btn-block btn-flat">登录</button>
            </div>
            <div> <span id="login_error" style="color: red;visibility: hidden">用户名密码不匹配,请重新输入</span></div>

            <!-- /.col -->
        </div>
    </div>
    <!-- /.login-box-body -->
</div>
<!-- /.login-box -->

<!-- jQuery 2.2.3 -->
<script th:src="@{/js/jquery-1.10.1.js}"></script>
<!-- Bootstrap 3.3.6 -->
<script th:src="@{/admin/bootstrap/js/bootstrap.min.js}" src="/static/bootstrap/js/bootstrap.min.js"></script>
<!-- iCheck -->
<script th:src="@{/admin/plugins/iCheck/icheck.min.js}" src="/static/plugins/iCheck/icheck.min.js"></script>
<script>
    $(function () {
        $("#submitId").click(function () {
            var user=$("#user").val();
            var pwd=$("#pwd").val();
            var veryfiy=true;
            if(user.length==0){
                $("#user_alert").css("visibility","visible");
                veryfiy=false;
            }else {
                $("#user_alert").css("visibility","hidden");
            }
            if(pwd.length==0){
                $("#pwd_alert").css("visibility","visible");
                veryfiy=false;
            }else {
                $("#pwd_alert").css("visibility","hidden");
            }
            if(veryfiy){
                //ajax提交表单
                var  json={
                    'adminUserUsername':user,
                    'adminUserPassword':pwd
                }
                $.ajax({
                    type:"POST",
                    url:"/admin/login/check",
                    dataType:"json",
                    data:JSON.stringify(json),
                    contentType:"application/json",
                    success:function (data) {
                        if(data=="login_succ"){
                            window.location.href="/admin/home";
                        }
                        else{
                            $("#login_error").css("visibility","visible");
                        }
                    }
                });
            }
        });
    });
</script>
</body>
</html>
